]> dgit.raspbian.org Git - kf6-kio.git/commitdiff
[PATCH] WidgetsAskUserActionHandler: show the SSL error dialog on the GUI thread
authorShouvik Kar <auxcorelabs@gmail.com>
Fri, 17 Jul 2026 18:17:04 +0000 (18:17 +0000)
committerAurélien COUDERC <coucouf@debian.org>
Sun, 26 Jul 2026 21:35:19 +0000 (23:35 +0200)
askIgnoreSslErrors() can be called from a non-GUI thread (e.g. the weather
ion runs its KIO jobs on a worker thread), where it constructed the
KMessageDialog off the GUI thread and crashed while painting it.

Marshal the dialog onto the GUI thread with QMetaObject::invokeMethod(qGuiApp,
...), like every other handler in this class already does.

BUG: 519614

Gbp-Pq: Name upstream_dd40b4c0_WidgetsAskUserActionHandler-show-the-SSL-error-dialog-on-the-GUI-thread.patch

src/widgets/widgetsaskuseractionhandler.cpp

index db8d895a9d346123e653d4de8ba5e7a300ed210a..85aedca460cfa8daf34a31ff08518ec11b25e72d 100644 (file)
@@ -502,32 +502,34 @@ void KIO::WidgetsAskUserActionHandler::setWindow(QWidget *window)
 
 void KIO::WidgetsAskUserActionHandler::askIgnoreSslErrors(const QVariantMap &sslErrorData, QWidget *parent)
 {
-    QWidget *parentWidget = d->getParentWidget(parent);
+    QMetaObject::invokeMethod(qGuiApp, [=, this] {
+        QWidget *parentWidget = d->getParentWidget(parent);
 
-    QString message = i18n("The server failed the authenticity check (%1).\n\n", sslErrorData[QLatin1String("hostname")].toString());
+        QString message = i18n("The server failed the authenticity check (%1).\n\n", sslErrorData[QLatin1String("hostname")].toString());
 
-    message += sslErrorData[QLatin1String("sslError")].toString();
+        message += sslErrorData[QLatin1String("sslError")].toString();
 
-    auto *dialog = new KMessageDialog(KMessageDialog::WarningTwoActionsCancel, message, parentWidget);
+        auto *dialog = new KMessageDialog(KMessageDialog::WarningTwoActionsCancel, message, parentWidget);
 
-    dialog->setAttribute(Qt::WA_DeleteOnClose);
-    dialog->setCaption(i18n("Server Authentication"));
-    dialog->setIcon(QIcon{});
-    dialog->setButtons(KGuiItem{i18n("&Details"), QStringLiteral("documentinfo")}, KStandardGuiItem::cont(), KStandardGuiItem::cancel());
+        dialog->setAttribute(Qt::WA_DeleteOnClose);
+        dialog->setCaption(i18n("Server Authentication"));
+        dialog->setIcon(QIcon{});
+        dialog->setButtons(KGuiItem{i18n("&Details"), QStringLiteral("documentinfo")}, KStandardGuiItem::cont(), KStandardGuiItem::cancel());
+
+        connect(dialog, &KMessageDialog::finished, this, [this, parentWidget, sslErrorData](int result) {
+            if (result == KMessageDialog::PrimaryAction) {
+                showSslDetails(sslErrorData, parentWidget);
+            } else if (result == KMessageDialog::SecondaryAction) {
+                // continue();
+                Q_EMIT askIgnoreSslErrorsResult(1);
+            } else if (result == KMessageDialog::Cancel) {
+                // cancel();
+                Q_EMIT askIgnoreSslErrorsResult(0);
+            }
+        });
 
-    connect(dialog, &KMessageDialog::finished, this, [this, parentWidget, sslErrorData](int result) {
-        if (result == KMessageDialog::PrimaryAction) {
-            showSslDetails(sslErrorData, parentWidget);
-        } else if (result == KMessageDialog::SecondaryAction) {
-            // continue();
-            Q_EMIT askIgnoreSslErrorsResult(1);
-        } else if (result == KMessageDialog::Cancel) {
-            // cancel();
-            Q_EMIT askIgnoreSslErrorsResult(0);
-        }
+        dialog->show();
     });
-
-    dialog->show();
 }
 
 void KIO::WidgetsAskUserActionHandler::showSslDetails(const QVariantMap &sslErrorData, QWidget *parentWidget)